// import { LogInfoPlugin } from "enhanced-resolve";
import React, { Component } from "react";

export class Header extends Component {
  state={
    content:[]
  }
  addTask =(e)=>{
    this.setState({
      content:e.target.value
    },()=>{
      console.log(this.state.content);
    })
    
  }
  confirm = (e)=>{
    console.log(e.keyCode);
    if(e.keyCode === 13){
      this.props.addList(this.state.content)
    }
  }
  render() {
    return (
      <header className="header">
        <h1>todos</h1>
        <input
          className="new-todo"
          placeholder="What needs to be done?"
          autoFocus
          value={this.content}
          onChange={this.addTask}
          onKeyDown={this.confirm}
        />
      </header>
    );
  }
}

export default Header;
